home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / DCLAP 6d / dclap6d / Drtf / DDrawPICT.h < prev    next >
Text File  |  1996-07-05  |  4KB  |  153 lines

  1. // DDrawPICT.h
  2.  
  3. #ifndef _DDRAWPICT_
  4. #define _DDRAWPICT_
  5.  
  6.  
  7. #include <Dvibrant.h>
  8.  
  9.  
  10. struct PictHeader {
  11.     short picsize;  // real size may be > 32k
  12.     short top;
  13.     short left;
  14.     short bottom;
  15.     short right;
  16.     char  data[4]; // lots of data here (4 is dummy val)
  17. };
  18.  
  19. struct RGBkolor {
  20.     unsigned short red;
  21.     unsigned short green;
  22.     unsigned short blue;
  23. };
  24.  
  25. struct qRect {
  26.     unsigned short top;
  27.     unsigned short left;
  28.     unsigned short bottom;
  29.     unsigned short right;
  30. };
  31.  
  32. struct PIXMap {
  33.     struct qRect Bounds;  
  34.     unsigned short pmVersion;
  35.     unsigned short packType;
  36.     unsigned long packSize;
  37.     unsigned long hRes;
  38.     unsigned long vRes;
  39.     unsigned short pixelType;
  40.     unsigned short pixelSize;
  41.     unsigned short cmpCount;
  42.     unsigned short cmpSize;
  43.     unsigned long planeBytes;
  44.     unsigned long pmTable;
  45.     unsigned long pmReserved;
  46. };
  47.  
  48. typedef PIXMap *PIXMapPtr;
  49.  
  50. struct KolorSpec {
  51.     unsigned short value;
  52.     RGBkolor     rgb;
  53. };
  54.  
  55. struct KolorTable {
  56.     unsigned long        ctSeed;
  57.     unsigned short    ctFlags;
  58.     unsigned short    ctSize;
  59.     KolorSpec    * ctTable;
  60. };
  61.     
  62.  
  63.  
  64. class DDrawPict 
  65. {
  66. public:
  67.             // DRichStyles uses same kinds !
  68.     enum kinds {
  69.         kPictOther= 0,
  70.          kPictMac= 1,
  71.          kPictWinMeta=2,
  72.          kPictPMMeta=3,
  73.          kPictDIBits=4,
  74.          kPictWinBits=5,
  75.          kPictGIF=6
  76.         };
  77.     enum { kXColorTableFlag = 1024 };
  78.         
  79.     static  void Pixmap2Xcolors( KolorTable& kolorTab, unsigned char* bits, ulong bitsize,
  80.                                                                 Nlm_Boolean returnXtabInBits = false);
  81.     static    void Cleanup(); // call at program termination, or when done using DrawPict stuff
  82.  
  83.     DDrawPict();
  84.     virtual ~DDrawPict();
  85.     void*   IsPICT( void* pictdata, ulong datasize, 
  86.                                     Nlm_Boolean dontTestForHeader = false);
  87.     virtual void Draw( Nlm_RectPtr r, void* pictdata, ulong picsize, short kind);
  88.     virtual void GetFrame( Nlm_RectPtr r, void* pictdata, ulong picsize, short kind);
  89.     
  90. protected:
  91.     short            fPictVersion;
  92.     RGBkolor     fOpcolor;
  93.     Nlm_Boolean        fVerbose, fPenshown, fUnclipped;
  94.     unsigned char        * fPict;
  95.     ulong        fPicsize, fAlign;
  96.     Nlm_RecT    fPicRect, fPicFrame, fTheRect;
  97.     Nlm_PoinT    fOvSize;
  98.     Nlm_FonT    fFont;
  99.     char         *    fFontname,  * fFontfamily;
  100.     short            fFontsize, fFontstyle;
  101.     char            fLastFontname[257];
  102.     short            fLastFontnum;
  103.     Nlm_Boolean        fNeedInstallFont;
  104.     
  105.     unsigned char    getByte();
  106.     unsigned short     getWord();
  107.     unsigned long getLong();
  108.     void     skipbytes( unsigned short count);
  109.     void     getbytes( char* buf, long bufsize);
  110.     unsigned short     getOpcode();
  111.     void     getRGBKolor( RGBkolor* acolor);
  112.     void    getForeColor();
  113.     void    getBackColor();
  114.     void    getPenMode();
  115.     void     getPointAsis( Nlm_PointPtr apt);
  116.     void     getPointLocal( Nlm_PointPtr apt);
  117.     void     getRectLocal( Nlm_RectPtr arect);
  118.     void     getRectAsis( Nlm_RectPtr arect);
  119.     void     skipPolyOrRegion();
  120.  
  121.     void    handleRectOpcode( unsigned short opcode);
  122.     void    handleSameRectOpcode( unsigned short opcode);
  123.  
  124.     unsigned char* expandbuf( unsigned char* buf, short* len, short bitsPerPixel);
  125.     unsigned char* unpackbits( Nlm_RectPtr bounds, unsigned short rowBytes, 
  126.                                                             short pixelSize, ulong& unpackSize);
  127.     void unpackSmallLine( long irow, unsigned char* linebuf, unsigned char* bits, unsigned char* bitsend, 
  128.                                                 unsigned short rowBytes, short pixelSize);
  129.     void unpackBigLine( long irow, unsigned char* linebuf, unsigned char* bits, unsigned char* bitsend, 
  130.                                        unsigned short rowBytes, short pixelSize, short pkpixsize);
  131.                                                  
  132.     void     read_pixmap( PIXMapPtr p, unsigned short* rowBytes);
  133.     KolorTable read_colour_table();
  134.     void     read_pattern();
  135.     void     drawPixmap( short version, unsigned short rowBytes, short isregion );
  136.     void     drawBitmap( short version, short rowBytes, Nlm_Boolean isregion);
  137.     void    drawPixmapOp9A( short version );
  138.     void     InstallFont();
  139.     void     SetFont( unsigned short fontnum);
  140.     void     SetFontStyle( unsigned char fstyle);
  141.     void     SetFontSize( unsigned short fsize);
  142.     void     getAArc( Nlm_RectPtr arec, Nlm_PointPtr pt, Nlm_PointPtr pt1);
  143.     void     getAPoly( Nlm_RectPtr polybox, short* polycount, Nlm_PointPtr* thePoly);
  144.     void     getARgn( Nlm_RectPtr rgnbox, Nlm_RegioN* theRgn, Nlm_Boolean forclip);
  145.     void  MakeXByteFlip();
  146.  
  147.  
  148. };
  149.  
  150.  
  151. #endif
  152.  
  153.